/*
<object id="flash1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="0" height="0">
	<param name="movie" value="WebSocket.swf" />
	<param name="quality" value="high" />
	<param name="wmode" value="transparent" />
	<embed src="WebSocket.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="0" height="0"></embed>
</object>
*/
function WebSocket(objId){
	//添加事件 onIOError:IO连接异常中断   onSocketData:获取到数据 
	//        onClose:连接关闭    onConnect:连接成功 
	this.addEvent = function(eventName, funName){
		return document.getElementById(objId).addEvent(eventName, funName);
	};
	this.open = function(host, port){//打开socket连接
		return document.getElementById(objId).open(host, port);
	};
	this.isOpen = function(){//socket连接是否是开启的
		return document.getElementById(objId).isOpen();
	};
	this.sendData = function(msg){//从socket发送信息
		return document.getElementById(objId).sendData(msg);
	};	
	this.close = function(){//关闭socket
		return document.getElementById(objId).close();
	};	
}

